<?php
/*********************************************
  CPG Dragonfly™ CMS
  ********************************************
  Copyright © 2004 - 2005 by CPG-Nuke Dev Team
  http://dragonflycms.org

  Dragonfly is released under the terms and conditions
  of the GNU GPL version 2 or any later version

  $Source: /cvs/html/themes/default/theme.php,v $
  $Revision: 1.32 $
  $Author: nanocaiordo $
  $Date: 2012/05/12 10:17:03 $
**********************************************/
if (!defined('CPG_NUKE')) { exit; }
define('THEME_VERSION', '10');

$gfxcolor = '#C0C000';
$bgcolor1 = '#FFFFFF';
$bgcolor2 = '#D3DFE3';
$bgcolor3 = '#EFEFEF';
$bgcolor4 = '#FFC53A';
$textcolor1 = '#009900';
$textcolor2 = '#000000';

function OpenTable() {
	echo '<div class="table1">';
}
function OpenTable2() {
	echo '<div class="table2">';
}

function CloseTable() {
	echo '</div>';
}
function CloseTable2() {
	echo '</div>';
}

function themeheader() {
	global $mainindex, $adminindex, $cpgtpl, $CPG_SESS, $MAIN_CFG, $Blocks, $Module;

	if ($MAIN_CFG['global']['admingraphic'] & 4) {
		CSS::add(THEME_PATH .'style/cpgmm.css', 'screen');
		if (is_file(THEME_PATH .'cssmainmenu.php')) {
			include(THEME_PATH .'cssmainmenu.php');
		} else {
			include('includes/cssmainmenu.php');
		}
	}

	CSS::add(THEME_PATH. 'style/'. Client::$name. '.css', 'screen');
	CSS::add(THEME_PATH. 'style/'. Client::$name. Client::$version. '.css', 'screen');

	JS::add(THEME_PATH. 'javascript/toggle.js');

	$cpgtpl->assign_vars(array(
		'CSS_DATA'      => CSS::flushToTpl(),
		'JS_DATA'       => JS::flushToTpl(),
		'PUBLIC_HEADER' => !defined('ADMIN_PAGES'),
		'S_IS_USER'     => is_user(),
		'S_LOGO'        => $MAIN_CFG['global']['site_logo'],
		'S_SITENAME'    => $MAIN_CFG['global']['sitename'],
		'S_HOME'        => _HOME,
		'S_DOWNLOADS'   => is_active('Downloads') ? _DownloadsLANG : false,
		'S_FORUMS'      => _ForumsLANG,
		'S_MY_ACCOUNT'  => is_user() ? _Your_AccountLANG : _BREG,
		'S_ADMIN'       => _ADMINISTRATION,
		'S_BANNER'      => ($MAIN_CFG['global']['banners']) ? viewbanner() : '',
		'U_MAININDEX'   => $mainindex,
		'U_DOWNLOADS'   => URL::index('Downloads'),
		'U_FORUMS'      => URL::index('Forums'),
		'U_MY_ACCOUNT'  => URL::index(is_user() ? 'Your_Account' : 'Your_Account&amp;file=register'),
		'U_ADMININDEX'  => $adminindex,
		'RSS_DATA'      => $Module->active && is_file($Module->chroot .'feed_rss.inc') ? '?feed='. $Module->name : false
	));
}

function themefooter() {
	global $cpgtpl, $Module;
	$cpgtpl->assign_vars(array(
		'S_FOOTER'      => footmsg()
	));
	$cpgtpl->set_filenames(array('footer' => 'footer.html'));
	$cpgtpl->display('footer');
}

/***********************************************************************************

 string theme_open_form

 Creates start tag for form
	$link : link for action default blank
	$form_name : useful for styling and nbbcode
	$legend: optional string value is used in form lagend tag
	$border: optional use 1 to not show border on fieldset from stylesheet
************************************************************************************/
function theme_open_form($link, $form_name=false, $legend=false, $tborder=false) {
	$leg = $legend ? "<legend>$legend</legend>" : '';
	$bord = $tborder ? $tborder : '';
	$form_name	= $form_name ? ' id="'.$form_name.'"' :'';
	return '<form method="post" action="'.$link.'"'.$form_name.' enctype="multipart/form-data" accept-charset="utf-8"><fieldset '.$bord.'>'.$leg;
}
function theme_close_form() {
	return '</fieldset></form>';
}
/***********************************************************************************

 string theme_yesno_option

 Creates 2 radio buttons with a Yes and No option
	$name : name for the <input>
	$value: current value, 1 = yes, 0 = no

************************************************************************************/
function theme_yesno_option($name, $value=0) {
	$sel[(!$value)] = '';
	$sel[$value] = ' selected="selected"';
	$select = '<select class="set" name="'.$name.'" id="'.$name."\">\n";
	$select .= '<option value="1"'.$sel[1].">"._YES."</option>\n";
	$select .= '<option value="0"'.$sel[0].">"._NO."</option>\n";
	return $select.'</select>';
}
/***********************************************************************************

 string theme_select_option

 Creates a selection dropdown box of all given variables in the array
	$name : name for the <select>
	$value: current/default value
	$array: array like array("value1","value2")

************************************************************************************/
function theme_select_option($name, $value, array $array) {
	$sel[$value] = ' selected="selected"';
	$select = '<select class="set" name="'.$name.'" id="'.$name."\">\n";
	foreach($array as $var) {
		$select .= '<option'.(isset($sel[$var])?$sel[$var]:'').">$var</option>\n";
	}
	return $select.'</select>';
}
/***********************************************************************************

 string theme_select_box

 Creates a selection dropdown box of all given variables in the multi array
	$name : name for the <select>
	$value: current/default value
	$array: array like array("value1 => title1","value2 => title2")

************************************************************************************/
function theme_select_box($name, $value, array $array) {
	$select = '<select class="set" name="'.$name.'" id="'.$name."\">\n";
	foreach($array as $val => $title) {
		$select .= "<option value=\"$val\"".(($val==$value)?' selected="selected"':'').">$title</option>\n";
	}
	return $select.'</select>';
}
